package com.example.test.dialogfactory;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.util.Consumer;
import easier.app.x.service.BinderService;
import easier.log.logger.Logger;

public class MainActivity60 extends AppCompatActivity {

    private Button mClick1;
    private Button mClick2;

    public static void start( Context context ) {

        Intent starter = new Intent( context, MainActivity60.class );
        context.startActivity( starter );
    }

    @Override
    protected void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main60 );
        initView();
    }

    private void initView() {

        mClick1 = (Button) findViewById( R.id.click1 );
        mClick1.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick( View v ) {

                BinderService.bindService( v.getContext(), Service60.class, new Consumer< Service60 >() {
                    @Override
                    public void accept( Service60 service60 ) {

                        Logger.d( service60 );
                    }
                } );
            }
        } );
        mClick2 = (Button) findViewById( R.id.click2 );
        mClick2.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick( View v ) {

                BinderService.bindService( v.getContext(), Service60.class, new Consumer< Service60 >() {
                    @Override
                    public void accept( Service60 service60 ) {

                        service60.destroy();
                    }
                } );
            }
        } );
    }
}